//
//  cliqsetAppDelegate.h
//  cliqset
//
//  Created by David Hinson on 2/6/09.
//  Copyright Sumner Systems Management, Inc. 2009. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "ContactDetailViewController.h"
#import "Database.h"
#import "Cliqset.h"
#import "SplashViewController.h"
#import "EditAddressViewController.h"
#import "EditEmailViewController.h"
#import "EditIMViewController.h"
#import "EditURLViewController.h"
#import "EditPhoneViewController.h"
#import "Status.h"
#import "Profile.h"

@interface cliqsetAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow *window;
    UITabBarController *tabBarController;
    IBOutlet UIViewController *loginViewController;
	
	NSMutableString *loginString;
	NSMutableString *passwordString;
	NSMutableString *authenticationString;
	NSMutableString *userString;
	
	BOOL isAuthenticated;
	BOOL isAuthenticating;
	BOOL isSyncing;
	BOOL reloadListView;
	BOOL updateContactsFlag;
	BOOL updateFavoritesFlag;
	
	NSMutableArray *contacts;
	NSMutableArray *favorites;
	NSMutableArray *toEvents;
	NSMutableArray *fromEvents;
	NSMutableArray *profileEvents;

	Database * database;
	
	Cliqset *cliqset;
	
	IBOutlet SplashViewController* splashViewController;
	
	NSTimer* viewTimer;
	NSTimer* watchDogTimer;
	
	NSMutableString * currentStatus;
	
	Profile * currentProfile;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) UIViewController *loginViewController;
@property (nonatomic, retain) IBOutlet SplashViewController *splashViewController;

@property BOOL isAuthenticated;
@property BOOL isAuthenticating;
@property BOOL isSyncing;
@property BOOL reloadListView;
@property BOOL updateContactsFlag;
@property BOOL updateFavoritesFlag;

@property (nonatomic, retain) NSTimer *viewTimer;
@property (nonatomic, retain) NSTimer *watchDogTimer;

@property (nonatomic, retain) NSString *loginString;
@property (nonatomic, retain) NSString *passwordString;
@property (nonatomic, retain) NSString *authenticationString;
@property (nonatomic, retain) NSString *userString;

@property (nonatomic, retain) NSMutableArray* contacts;
@property (nonatomic, retain) NSMutableArray* favorites;
@property (nonatomic, retain) NSMutableArray* toEvents;
@property (nonatomic, retain) NSMutableArray* fromEvents;
@property (nonatomic, retain) NSMutableArray* profileEvents;

@property (nonatomic, retain) Cliqset* cliqset;
@property (nonatomic, retain) Database* database;

@property (retain, nonatomic) NSMutableString * currentStatus;
@property (retain, nonatomic) Profile * currentProfile;

-(void)addTextToLog:(NSString *)text withCaption:(NSString *)caption;
-(void)flipLoginToBack;
-(void)flipLoginToFront;
-(void)flipSplashToBack;
-(void)flipSplashToFront;

-(void)slideAddressIn:(ContactDetailViewController*)parent label:(NSString*)label street:(NSString*)street locality:(NSString*)locality region:(NSString*)region postalCode:(NSString*)postalCode country:(NSString *)country;
-(void)slideAddressTypeIn:(EditAddressViewController*)parent;
-(void)slideAddressTypeOut:(EditAddressViewController*)parent;
-(void)slideAddressOut;

-(void)slideAddContactIn:(NSInteger)index;
-(void)slideContactIn:(NSInteger)index;
-(void)slideContactOut;
-(void)slideFavoriteIn:(NSInteger)index;
-(void)slideFavoriteOut;
-(void)slideEmailIn:(ContactDetailViewController*)parent label:(NSString*)label content:(NSString*)content;
-(void)slideEmailOut;
-(void)slideEmailTypeIn:(EditEmailViewController*)parent;
-(void)slideEmailTypeOut:(EditEmailViewController*)parent;
-(void)slideIMTypeIn:(EditIMViewController*)parent;
-(void)slideIMTypeOut:(EditIMViewController*)parent;
-(void)slideIMIn:(ContactDetailViewController*)parent label:(NSString*)label content:(NSString*)content;
-(void)slideIMOut;
-(void)slideURLIn:(ContactDetailViewController*)parent label:(NSString*)label content:(NSString*)content;
-(void)slideURLOut;
-(void)slideURLTypeOut:(EditURLViewController*)parent;
-(void)slideURLTypeIn:(EditURLViewController*)parent;
-(void)slidePhoneIn:(ContactDetailViewController*)parent label:(NSString*)label content:(NSString*)content;
-(void)slidePhoneOut;
-(void)slidePhoneTypeIn:(EditPhoneViewController*)parent;
-(void)slidePhoneTypeOut:(EditPhoneViewController*)parent;
-(void)slideProfileIn:(NSInteger)index;
-(void)slideUserIn:(ContactDetailViewController*)parent givenName:(NSString*)givenName familyName:(NSString*)familyName position:(NSString*)position company:(NSString*)company;
-(void)slideUserOut;
-(void)reloadContactsTable;
-(void)reloadFavoritesTable;
-(void)reloadEventsTable;
-(void)reloadProfileTable;
-(void)showContactsHoverView:(BOOL)show;
-(void)showFavoritesHoverView;
-(void)showProfileHoverView:(BOOL)show;
-(void)showEventsHoverView:(BOOL)show;
-(void)showEventsBadge:(NSString*)badge;
-(void)showContactsBadge:(NSString*)badge;

// --- Timers
-(void)resetTimer;
-(void)resetWatchDogTimer;

// --- Misc
-(void)resetSegment;

-(IBAction)logout:(id)id;

@end
